//
//  UploadSettingViewController.m
//  Rail
//
//  Created by hychen on 2018/2/25.
//  Copyright © 2018年 Hychen. All rights reserved.
//

#import "UploadSettingViewController.h"

@interface UploadSettingViewController ()

@end

@implementation UploadSettingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.tableView setScrollEnabled:NO];
    [self.navigationItem addSimpleTitleView:@"设置"];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)czh_setGroup
{
    [super czh_setGroup];

    BMWeakSelf
    CZHSwitchItem *set1 = [CZHSwitchItem itemWithImageName:nil title:@"2g/3g/4g网络播放视频提示" canClick:YES haveLine:YES];
    set1.isOn = ![UserDefaults_bb boolForKey:Key_4G_PlayVideo];
    CZHSettingFrameModel *set1Model = [[CZHSettingFrameModel alloc] init];
    set1Model.item = set1;
    
    CZHSwitchItem *set2 = [CZHSwitchItem itemWithImageName:nil title:@"2g/3g/4g网络自动上传" canClick:YES haveLine:YES];
    set2.isOn = [UserDefaults_bb boolForKey:Key_4G_AutoUpload];
    CZHSettingFrameModel *set2Model = [[CZHSettingFrameModel alloc] init];
    set2Model.item = set2;
    
    set1.switchBlock = ^(CZHSwitchItem *item, NSIndexPath *indexPath, BOOL isOn) {
        //WIFI网络自动下载更新包
        [UserDefaults_bb setBool:!isOn forKey:Key_4G_PlayVideo];
        item.isOn = isOn;
        set1Model.item = item;
        [weakSelf.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
    };
    
    set2.switchBlock = ^(CZHSwitchItem *item, NSIndexPath *indexPath, BOOL isOn) {
        [UserDefaults_bb setBool:isOn forKey:Key_4G_AutoUpload];
        item.isOn = isOn;
        set2Model.item = item;
        [weakSelf.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
    };
    
    CZHSectionItem *sectionZero = [[CZHSectionItem alloc] init];
    sectionZero.items = @[set1Model,set2Model];
    [self.sectionGroups addObject:sectionZero];

}

@end
